package com.ruoyi.test.dao;
import com.ruoyi.test.domain.Person;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
 * 数据层
 */
@Mapper
public interface PersonDao {

    @Select("select * from t_person order by username desc")
    List<Person> listAllPersonOrderByUsername();

    /**
     * 查询所有
     *
     * @return 列表
     */
    @Select("select * from t_person")
    List<Person> listAll();

    @Select("select count(1) from t_person t where t.username = #{username} and t.password = #{password}")
    int login(Person vo);

    //在mapper.xml中实现
    int add(Person vo);

    @Select("select * from t_person where username = #{username} or id = #{id}")
    Person findPerson(Person vo);


    //在mapper.xml中实现
    int update(Person vo);

    /**
     * 删除
     * @param id
     * @return
     */
    @Delete("delete from t_person where id = #{id}")
    int delete(String id);

    /**
     * 根据ID或username查询
     * @param
     * @return
     */
    @Select("select t.* from t_person t where t.id = #{param} or t.username = #{param}")
    Person getOne(String param);

    @Select("select t.* from t_person t where t.username = #{username}")
    Person findByUsername(String username);

}
